{# What is in the cache, by family (the first two parts of a key): how much room each takes and whether it earns it. A family that takes room and is rarely hit is the one to shorten or drop. Hits and misses count the process serving this page; with Redis the entries are shared, the counts are not. #} {% from "components/macros/layout.html" import card, stats_strip, progress, badge %} {% from "components/macros/table.html" import data_table %} {% from "components/macros/feedback.html" import empty_state %} {% macro share(value) %}{{ progress(value, "ok", size="h-1.5") }}{{ (value * 100)|round(1) }}%{% endmacro %} {% macro rate(value) %}{% if value is none %}-{% else %}{{ badge(value ~ "%", "ok" if value >= 80 else ("warn" if value >= 50 else "error")) }}{% endif %}{% endmacro %} {% if cache.error %}
The cache could not be read ({{ cache.backend }}): {{ cache.error }}
{% else %}Backend: {{ "Redis (shared by every process)" if cache.backend == "redis" else "memory (this process only)" }}
{% if not cache.families %} {{ empty_state("The cache is empty", "Services put values here with app.core.cache; they appear once something is cached.") }} {% else %} {% call card("Families", "By room taken", id="cache-families") %} {{ data_table([ {"key": "family", "label": "Family", "kind": "code"}, {"key": "keys", "label": "Keys", "kind": "int", "align": "right"}, {"key": "size", "label": "Size", "align": "right"}, {"key": "share", "label": "Share", "render": share}, {"key": "ttl_label", "label": "Avg time left"}, {"key": "hit_rate", "label": "Hit rate", "render": rate}, ], cache.families) }} {% endcall %} {% call card("Largest keys", id="cache-largest") %} {{ data_table([ {"key": "key", "label": "Key", "kind": "code"}, {"key": "size", "label": "Size", "align": "right"}, {"key": "ttl_label", "label": "Time left"}, ], cache.largest) }} {% endcall %} {% endif %}